import Vue from 'vue'
import Router from 'vue-router'
import App from './App'
import routes from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-default/index.css'
import echarts from 'echarts'
import iView from 'iview' // 引入iview依赖
import 'iview/dist/styles/iview.css' // 引入iview css样式
Vue.prototype.$echarts = echarts
Vue.use(Router)
Vue.use(ElementUI)
Vue.use(iView) //使用iview组件 
const router = new Router({
    routes
});

router.beforeEach((to, from, next) => {
    if (to.path == '/login') {
        sessionStorage.removeItem('user');
    }
    let user = JSON.parse(sessionStorage.getItem('user'));
    if (!user && to.path != '/login') {
        next({
            path: '/login'
        });
    } else {
        next();
    }
});

Vue.config.productionTip = false
    // import router from './router'
new Vue({
    router,
    render: h => h(App)
}).$mount('#app')